<template>
	<view class="content">
		<scroll-view style="height: 100vh;" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view style="height: 1rpx;"></view>
			<view v-if="list.length == 0" class="wid90 mar fowe800 foSi35">
				<view style="height: 50rpx;"></view>
				<view class="dis disJuC">
					<image src="../../static/zanwu2.png" style="width: 400rpx;height: 300rpx;"></image>
				</view>
				<view class="textCen mar-top20" style="color: #868686;">暂无数据</view>
			</view>
			<block v-for="(item,index) in list" :key="index">
				<view class="wid90 mar bacFFF borRad20 mar-top30 fowe600" @click="tiaozhuan('/pages/verification/particulars?id='+item.id+'&name='+name)">
					<view class="dis disAl disJuB wid90 mar hei80">
						<view v-if="item.writeoff_state == 1" class="foSi20" style="color: #5B5B5B;">核销时间：{{dateFormat(item.writeofftime)}}</view>
						<view v-if="item.writeoff_state == 0" class="foSi20" style="color: #5B5B5B;">兑换时间：{{item.createtime}}</view>
						<view v-if="item.writeoff_state == 1" class="foSi25" style="color: #035DFF;">已核销</view>
						<view v-if="item.writeoff_state == 0" class="foSi25" style="color: #FE6522;">未核销</view>
					</view>
					<view class="wid100 xia"></view>
					<view class="dis disAl disJuB wid90 mar" style="padding: 20rpx 0;">
						<view class="dis foSi30">
							<view>{{item.name}}</view>
							<view class="mar-left10">{{item.mobile}}</view>
						</view>
						<view style="color: #035DFF;text-align: right;">
							<view class="foSi30">{{item.goods.name}}</view>
							<view class="mar-top10 foSi25">-{{item.num}}</view>
						</view>
					</view>
					<view v-if="item.writeoff_state == 1" class="wid100 xia"></view>
					<view v-if="item.writeoff_state == 1" class="wid90 mar mar-top30 dis disAl disJuB foSi25" style="opacity: 0.7;">
						<view>核销门店</view>
						<view>{{name}}</view>
					</view>
					<view v-if="item.writeoff_state == 1" class="wid90 mar mar-top30 dis disAl disJuB foSi25" style="opacity: 0.7;">
						<view>核销店员</view>
						<view>{{item.clerk.name}}</view>
					</view>
					<view style="height: 40rpx;"></view>
				</view>
			</block>
			<view style="height: 50rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				last_page: 0,
				page: 1,
				list: [],
				yuan_userinfo: '',
				name: ''
			}
		},
		onLoad(option) {
			this.name = option.name
			this.yuan_userinfo = uni.getStorageSync('yuan_userinfo')
			this.getList()
		},
		onShow() {},
		methods: {
			dateFormat(time) {
				let date = new Date(time*1000);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				// return year + "-" + month + "-" + day;
			},
			getList() {
				var that = this;
				console.log('clerk_id');
				console.log(that.yuan_userinfo.id);
				uni.request({
					url: that.global.url + 'api/qianyu_petrol/gasstation_clerk_write',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						gas_station_id: that.yuan_userinfo.gas_station_id,
						page: that.page,
						limit: 10,
						clerk_id: that.yuan_userinfo.id
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.last_page = result.data.last_page
							that.list = that.list.concat(result.data.data)
						}
					}
				})
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background: #F8F9FD;
		height: 100vh;
	}
	.xia{
		height: 1rpx;
		background-color: #E5E5E5;
	}
</style>
